#include "global.h"

static bank3 unsigned char dt_window=0;
static bank3 unsigned int dt_window_time_counter=0;
static bank3 unsigned char Pass =0;
static bank3 unsigned char CompressorLockCounter=0;


unsigned char *timebuff;
const unsigned char *display_message;

const unsigned char* p_message;

void setMainWindow(void)
{
	dt_window =0;
	dt_window_time_counter=0;
};

void DoTest(void)
{	unsigned int dt_int_temp;
	unsigned char dt_temp;


	if (dt_window_time_counter++ > 400)
	{	
		dt_window_time_counter=0;
		if (++dt_window >1) dt_window=0;
		ClearLCD();
	};
	rest_of_test=test_duration-getgSec();
	if (rest_of_test < 0)
	{
		rest_of_test=0;
		flag_sequence_running =0;
		flag_sequence_finished=1;	
	}
	if (flag_sequence_running)
	{
		switch (job_selector)
		{
			case 1: 
				rest_of_stage=DoSequenceJob(DCI_HITACHI_4HP,&myPreset,&p_message);
				break;
			case 2:
				rest_of_stage=DoSequenceJob(DCI_HITACHI_5HP,&myPreset,&p_message);
				break;
			case 3:
				rest_of_stage=DoSequenceJob(DCI_TOSHIBA_6HP,&myPreset,&p_message);
				break;
			case 4: 
				rest_of_stage=DoSequenceJob(DCI_ELECTRA_4HP,&myPreset,&p_message);
				break;
			case 5:
				rest_of_stage=DoSequenceJob(DCI_TOSHIBA_4HP,&myPreset,&p_message);
				break;
			case 6:
				rest_of_stage=DoSequenceJob(DCI_TOSHIBA_5HP,&myPreset,&p_message);
				break;

			default:
				ClearLCD();
				CursorPosLCD(1,0);
				printf ("       ERROR        ");
				CursorPosLCD(2,0);
				printf ("   Wrong Sequence   ");
				CursorPosLCD(3,0);
				printf ("     selection      ");			
				flag_sequence_running = 0;
				flag_sequence_running = 0;
				while(1);
				break;
			};	
	
	};



	switch (dt_window)
	{	case 0:
				CursorPosLCD(1,0);
				printf(p_message);
				CursorPosLCD(2,0);
				ShowSTime(rest_of_test,time) ;
				printf ("%s    ",time);

				CursorPosLCD(2,10);
				ShowSTime(rest_of_stage,time);
				printf ("%s   ",time);
				CursorPosLCD(3,0);

//			//	if ((2 == mssg_index)&&(MyODU.Data.ODUBasicData.OEnvCompActFreq >15 ))
//
//				{
//					printf("___ OPEN__VALVES ___");
//				}
//				else
//				{
					printf("HST:%dC ",MyODU.Data.ODUExtraData.OEnvHST);
					CursorPosLCD(3,10);
					printf ("f=%d/%dHz ",myPreset.Compressor_freq,MyODU.Data.ODUBasicData.OEnvCompActFreq);			
//				}	

				CursorPosLCD(4,0);
				ShowCurrent(MyODU.Data.ODUBasicData.OEnvCompCur,time);
				printf("Iac %sA",time);
			
				CursorPosLCD(4,10);
				ShowCurrent(MyODU.Data.ODUExtraData.OEnvCompDCCurr,time );
				printf ("Idc %sA",time);
				break;
		
		case 1:
				CursorPosLCD(1,0);
				printf ("Model %s",model_name[job_selector]);

				CursorPosLCD(2,0);

				dt_temp = MyODU.Data.ODUBasicData.OOprLstFlr&0b00011111;
				if (
					(dt_temp!= 27)&&
					(dt_temp != 0)&&
					(dt_temp != 0)&&
					(dt_temp !=0 ))
				{						
					printf("%s", Error_explanation[dt_temp]);
				}
			
				CursorPosLCD(3,0);
				printf("OCT:%dC  ",MyODU.Data.ODUExtraData.OEnvOCT);
			
				CursorPosLCD(3,10);
				printf("OMT:%dC  ",MyODU.Data.ODUExtraData.OEnvOMT);
			
				CursorPosLCD(4,0);
				printf("CTT:%dC  ",MyODU.Data.ODUExtraData.OEnvCTT);
			
				CursorPosLCD(4,10);
				printf("OAT:%dC  ",MyODU.Data.ODUExtraData.OEnvOAT);
				break;

		case 2:
				CursorPosLCD(2,0);
				printf ("WINDOW3");

				CursorPosLCD(2,10);
				printf ("smth");
			
				CursorPosLCD(3,0);
				printf ("smth");
			
				CursorPosLCD(3,10);
				printf ("smth");
			
				CursorPosLCD(4,0);
				printf ("smth");
			
				CursorPosLCD(4,10);
				printf ("smth");
				break;
		}; // end of switch
};

